#pragma once

#include "common_data.h"
#include "broker.h"

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <ev.h>
#include <assert.h>

#define TLM_SERVER_PORT 48700
#define TLM_SERVER_IP INADDR_ANY
#define TLM_SRV_PERIOD 1.0

#ifdef __cplusplus
extern "C" {
#endif

typedef struct{
  ev_timer timer;
  int sock;
  struct bcshm_t shm;
} TLM_TIMER_t;


int tlm_srv_init();

void tlm_srv_start();

static void main_timer_cb(EV_P_ ev_timer *w, int revents);

void send_tlm(int sock, gcs_tlm_t* tlm);

int recv_tlm(int sock, gcs_tlm_t* tlm);

#ifdef __cplusplus
extern "C" {
#endif

